package com.fengxing.ams.web.facade;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.fengxing.ams.web.facade.intf.IMajorFacade;
import com.fengxing.ams.web.facade.mouble.major.CollegeMajorVO;
import com.fengxing.ams.web.facade.mouble.major.ICollegeMajorDAO;
import com.fengxing.ams.web.facade.mouble.major.IMajorDescriptionDAO;
import com.fengxing.ams.web.facade.mouble.major.MajorDescriptionVO;

@Component
@Transactional
public class MajorFacade implements IMajorFacade {
	@Autowired
	IMajorDescriptionDAO majorDescriptionDAO;
	@Autowired
	ICollegeMajorDAO collegeMajorDAO;

	@Override
	public MajorDescriptionVO getMajorDescription (Integer majorId) {
		return majorDescriptionDAO.findOne(majorId);
	}

	@Override
	public List<MajorDescriptionVO> getMajorDescriptionAll() {
		List<MajorDescriptionVO> vos = new ArrayList<MajorDescriptionVO> ();
		Iterator<MajorDescriptionVO> iter = this.majorDescriptionDAO.findAll().iterator();
		while (iter.hasNext()) {
			vos.add(iter.next());
		}
		return vos;
	}

	@Override
	public List<MajorDescriptionVO> getMajorDescriptionAll(String education) {
		return majorDescriptionDAO.getMajorDescriptionByEducation(education);
	}

	@Override
	public List<CollegeMajorVO> getCollegeByDescriptionId(Integer description_id) {
		return collegeMajorDAO.getMapByDescriptionId(description_id);
	}
	
}
